import React from 'react';
import ReactDOM from 'react-dom';
//import injectTapEventPlugin from 'react-tap-event-plugin';
import Button from "../../../node_modules/react-bootstrap/lib/Button";
import Modal from "../../../node_modules/react-bootstrap/lib/Modal";
//injectTapEventPlugin();

let Alert = React.createClass({
    getInitialState: function () {
        return {
            open: false,
            msg:""
        }
    },
    componentWillMount:function(){
        var obThis = this;
        window.alert = function(msg){
            obThis.setState({
                open: true,
                msg:msg
            });
        }
    },
    handleOpen: function () {
        this.setState({open: true});
    },

    handleClose: function () {
        this.setState({open: false});
    },
    render() {
        return (
            <Modal
                show={this.state.open}
                style={{borderRadius:"0",height:"300px",width:"500px"}}
            >
                <Modal.Header style={{background:"#383F45"}}>
                    <Modal.Title style={{color:"white"}}>
                        <img src="/res/image/prompt.png" style={{float:"left"}}/>
                        <span style={{marginLeft: "10px",letterSpacing:"2px"}}>提示</span>
                        <img src="/res/image/close.png" style={{float:"right",cursor:"pointer",marginTop:" 5.5px"}}
                             onClick={this.handleClose}/>
                    </Modal.Title>
                </Modal.Header>
                <Modal.Body style={{textAlign: "center",paddingTop: "50px"}}>
                    {this.state.msg}
                </Modal.Body>
                <Modal.Footer style = {{textAlign: "center",border: "none",fontFamily:'Microsoft YaHei'}}>
                    <Button onClick={this.handleClose}
                            style={{backgroundColor: "#555", borderColor: "#555",width:"70px",margin:'12'}}
                            bsStyle="primary">确定</Button>
                </Modal.Footer>
            </Modal>
        );
    }
});
module.exports = Alert;
